home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / LPC05B.ARJ / MATDUMP.C < prev    next >
C/C++ Source or Header  |  1992-05-22  |  1KB  |  66 lines

  1. /*
  2. *-----------------------------------------------------------------------------
  3. *    file:    matdump.c
  4. *    desc:    matrix mathematics - object dump
  5. *    by:    ko shu pui, patrick
  6. *    date:    24 nov 91 v0.1
  7. *    revi:    14 may 92 v0.2
  8. *    ref:
  9. *       [1] Mary L.Boas, "Mathematical Methods in the Physical Sciene,"
  10. *    John Wiley & Sons, 2nd Ed., 1983. Chap 3.
  11. *
  12. *    [2] Kendall E.Atkinson, "An Introduction to Numberical Analysis,"
  13. *    John Wiley & Sons, 1978.
  14. *
  15. *-----------------------------------------------------------------------------
  16. */
  17. #include <stdio.h>
  18. #include "matrix.h"
  19.  
  20. /*
  21. *-----------------------------------------------------------------------------
  22. *    funct:    mat_dump
  23. *    desct:    dump a matrix
  24. *    given:    A = matrice to dumped
  25. *    retrn:    nothing
  26. *    comen:    matrix a dumped to standard output
  27. *-----------------------------------------------------------------------------
  28. */
  29. MATRIX mat_dump( A )
  30. MATRIX A;
  31. {
  32.     int    i, j;
  33.  
  34.     for (i=0; i<MatRow(A); i++)
  35.         {
  36.         for (j=0; j<MatCol(A); j++)
  37.             {
  38.             fprintf( stdout, "%f ", A[i][j] );
  39.             }
  40.         fprintf( stdout, "\n" );
  41.         }
  42.  
  43.     return (A);
  44. }
  45.  
  46. MATRIX mat_fdump( A, fp )
  47. MATRIX A;
  48. FILE *fp;
  49. {
  50.     int     i, j;
  51.  
  52.     if (fp==NULL)
  53.         return ((MATRIX)mat_error( MAT_FNOTOPEN ));
  54.  
  55.     for (i=0; i<MatRow(A); i++)
  56.         {
  57.         for (j=0; j<MatCol(A); j++)
  58.             {
  59.             fprintf( fp, "%f ", A[i][j]);
  60.             }
  61.         fprintf( fp, "\n" );
  62.         }
  63.  
  64.     return (A);
  65. }
  66.